# -*- coding: utf-8 -*- 
#
# Description:
#
#  Definiton
#
#
#
# Changes:
#
# 2012-01-10
# Initial Commit
#
#
# Copyright 2010-2012, WyDev Team.
# Author: Polo35 (polo35580@hotmail.fr)
#
# Licenced under Academic Free License version 3.0
# Review WyGui README & LICENSE files for further details.

nname: 0
n 0(None)[return TNTAutomaticScanItem(parent=None, name=_('Yes'), menu=self.menu, type_='setupitem').execute()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76a5bac>}
nname: 0
n 0(None)[return self.menu._set_options_list(None)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76a59ac>}
nname: 0
n 0(None)[return [ActionItem(name=_('Yes'), type_='setupitem', action=(lambda : TNTAutomaticScanItem(parent=None, name=_('Yes'), menu=self.menu, type_='setupitem').execute())), ActionItem(name=_('No'), type_='setupitem', action=(lambda : self.menu._set_options_list(None)))]
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76a542c>}
nname: 6
n 6(None)[def browse(self):
	return [ActionItem(name=_('Yes'), type_='setupitem', action=(lambda : TNTAutomaticScanItem(parent=None, name=_('Yes'), menu=self.menu, type_='setupitem').execute())), ActionItem(name=_('No'), type_='setupitem', action=(lambda : self.menu._set_options_list(None)))]

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb76a4a8c>}
nname: 82
n 82(None)[UserConfigSetupItem.__init__(self, *args, **kw)
]:
	i: 9(AL), 77(), 81()
	o: 

nname: 81
n 81(None)[]:
	i: 0(t)
	o: 82()

nname: 77
n 77(None)[]:
	i: 13(AF), 27()
	o: 82()

nname: 27
n 27(None)[for d in config.HMI_TV['epg_margins']:
_d = d * 60
EPGMarginItem.translation_dict[d] = strftime(_('%M min'), gmtime(_d))
]:
	i: 13(for)
	o: 77()

nname: 13
n 13(None)[]:
	i: 9(loop)
	o: 27(for), 77(AF)

nname: 9
n 9(None)[]:
	i: 0(f)
	o: 13(loop), 82(AL)

nname: 0
n 0(EPGMarginItem.translation_dict)[]:
	i: 
	o: 9(f), 81(t)

nname: 82
n 82(None)[UserConfigSetupItem.__init__(self, *args, **kw)
]:
	i: 27(), 0(t)
	o: 

nname: 27
n 27(None)[for d in config.HMI_TV['epg_margins']:
	_d = d * 60
	EPGMarginItem.translation_dict[d] = strftime(_('%M min'), gmtime(_d))
]:
	i: 9(for)
	o: 82()

nname: 9
n 9(None)[]:
	i: 0(f)
	o: 27(for)

nname: 0
n 0(EPGMarginItem.translation_dict)[]:
	i: 
	o: 9(f), 82(t)

nname: 82
n 82(None)[UserConfigSetupItem.__init__(self, *args, **kw)
]:
	i: 9(), 0(t)
	o: 

nname: 9
n 9(None)[for d in config.HMI_TV['epg_margins']:
	_d = d * 60
	EPGMarginItem.translation_dict[d] = strftime(_('%M min'), gmtime(_d))
]:
	i: 0(f)
	o: 82()

nname: 0
n 0(EPGMarginItem.translation_dict)[]:
	i: 
	o: 9(f), 82(t)

nname: 0
n 0(None)[if not EPGMarginItem.translation_dict:
	for d in config.HMI_TV['epg_margins']:
		_d = d * 60
		EPGMarginItem.translation_dict[d] = strftime(_('%M min'), gmtime(_d))
UserConfigSetupItem.__init__(self, *args, **kw)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76a55cc>}
nname: 0
n 0(None)[UserConfigSetupItem._select_option(self, val)
WyRecord().setRecordPadding(val * 60)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76a520c>}
nname: 6
n 6(None)[depth = 2
translation_dict = {}
def __init__(self, *args, **args):
	if not EPGMarginItem.translation_dict:
		for d in config.HMI_TV['epg_margins']:
			_d = d * 60
			EPGMarginItem.translation_dict[d] = strftime(_('%M min'), gmtime(_d))
	UserConfigSetupItem.__init__(self, *args, **kw)

def _select_option(self, val):
	UserConfigSetupItem._select_option(self, val)
	WyRecord().setRecordPadding(val * 60)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb76a4c6c>}
nname: 145
n 145(None)[self.free_channels_only_item = ActionItem(_('Free channels only'), type_='setupitem', display_type='checked', action=self.set_include_scrambled, args=(False,))
self.preview_list = [self.all_channels_item, self.free_channels_only_item, TNTAutomaticScanItem(parent=self, name='Start scan', type_='setupitem')]
]:
	i: 134(), 141()
	o: 

nname: 141
n 141(None)[]:
	i: 77(f)
	o: 145()

nname: 134
n 134(None)[]:
	i: 77(t)
	o: 145()

nname: 77
n 77(self.include_scrambled)[self.all_channels_item = ActionItem(_('Free and pay channels'), type_='setupitem', display_type='not_checked', action=self.set_include_scrambled, args=(True,))
]:
	i: 66(), 73()
	o: 134(t), 141(f)

nname: 73
n 73(None)[]:
	i: 0(f)
	o: 77()

nname: 66
n 66(None)[]:
	i: 0(t)
	o: 77()

nname: 0
n 0(self.include_scrambled)[ParametersSetupItem.__init__(self, *args, **kw)
self.include_scrambled = user_config['tv']['scan_with_scrambled']
]:
	i: 
	o: 66(t), 73(f)

nname: 145
n 145(None)[self.free_channels_only_item = ActionItem(_('Free channels only'), type_='setupitem', display_type='checked', action=self.set_include_scrambled, args=(False,))
self.preview_list = [self.all_channels_item, self.free_channels_only_item, TNTAutomaticScanItem(parent=self, name='Start scan', type_='setupitem')]
]:
	i: 0()
	o: 

nname: 0
n 0(None)[ParametersSetupItem.__init__(self, *args, **kw)
self.include_scrambled = user_config['tv']['scan_with_scrambled']
if self.include_scrambled:
	pass
self.all_channels_item = ActionItem(_('Free and pay channels'), type_='setupitem', display_type='not_checked', action=self.set_include_scrambled, args=(True,))
if self.include_scrambled:
	pass
]:
	i: 
	o: 145()

nname: 0
n 0(None)[ParametersSetupItem.__init__(self, *args, **kw)
self.include_scrambled = user_config['tv']['scan_with_scrambled']
if self.include_scrambled:
	pass
self.all_channels_item = ActionItem(_('Free and pay channels'), type_='setupitem', display_type='not_checked', action=self.set_include_scrambled, args=(True,))
if self.include_scrambled:
	pass
self.free_channels_only_item = ActionItem(_('Free channels only'), type_='setupitem', display_type='checked', action=self.set_include_scrambled, args=(False,))
self.preview_list = [self.all_channels_item, self.free_channels_only_item, TNTAutomaticScanItem(parent=self, name='Start scan', type_='setupitem')]
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76a5fec>}
nname: 52
n 52(None)[self.free_channels_only_item.display_type = 'checked'
self.all_channels_item.reset_view()
self.free_channels_only_item.reset_view()
]:
	i: 41(), 48()
	o: 

nname: 48
n 48(None)[]:
	i: 26(f)
	o: 52()

nname: 41
n 41(None)[]:
	i: 26(t)
	o: 52()

nname: 26
n 26(value)[self.all_channels_item.display_type = 'not_checked'
]:
	i: 15(), 22()
	o: 41(t), 48(f)

nname: 22
n 22(None)[]:
	i: 0(f)
	o: 26()

nname: 15
n 15(None)[]:
	i: 0(t)
	o: 26()

nname: 0
n 0(value)[self.include_scrambled = value
]:
	i: 
	o: 15(t), 22(f)

nname: 52
n 52(None)[self.free_channels_only_item.display_type = 'checked'
self.all_channels_item.reset_view()
self.free_channels_only_item.reset_view()
]:
	i: 0()
	o: 

nname: 0
n 0(None)[self.include_scrambled = value
if value:
	pass
self.all_channels_item.display_type = 'not_checked'
if value:
	pass
]:
	i: 
	o: 52()

nname: 0
n 0(None)[self.include_scrambled = value
if value:
	pass
self.all_channels_item.display_type = 'not_checked'
if value:
	pass
self.free_channels_only_item.display_type = 'checked'
self.all_channels_item.reset_view()
self.free_channels_only_item.reset_view()
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76a54cc>}
nname: 6
n 6(None)[depth = 2
def __init__(self, *args, **args):
	ParametersSetupItem.__init__(self, *args, **kw)
	self.include_scrambled = user_config['tv']['scan_with_scrambled']
	if self.include_scrambled:
		pass
	self.all_channels_item = ActionItem(_('Free and pay channels'), type_='setupitem', display_type='not_checked', action=self.set_include_scrambled, args=(True,))
	if self.include_scrambled:
		pass
	self.free_channels_only_item = ActionItem(_('Free channels only'), type_='setupitem', display_type='checked', action=self.set_include_scrambled, args=(False,))
	self.preview_list = [self.all_channels_item, self.free_channels_only_item, TNTAutomaticScanItem(parent=self, name='Start scan', type_='setupitem')]

def set_include_scrambled(self, value):
	self.include_scrambled = value
	if value:
		pass
	self.all_channels_item.display_type = 'not_checked'
	if value:
		pass
	self.free_channels_only_item.display_type = 'checked'
	self.all_channels_item.reset_view()
	self.free_channels_only_item.reset_view()

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb76a4dcc>}
nname: 0
n 0(None)[wyscanserver().EnableHighLnbVoltage(1, value)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76a4f4c>}
nname: 6
n 6(None)[depth = 2
def execute_action(self, value):
	wyscanserver().EnableHighLnbVoltage(1, value)

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb76a4c6c>}
nname: 0
n 0(None)[ParametersSetupItem.__init__(self, *args, **kw)
self.parent = parent
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76a526c>}
nname: 0
n 0(None)[scan_item_list = [DVBSScanItem(wyscanserver(), name, antenna, transponder, scan_network, include_scrambled, menu=self.menu)]
user_config['tv']['scan_with_scrambled'] = include_scrambled
user_config.save()
scan_item_list[0].player.play(scan_item_list[0], playlist=scan_item_list, hide_previous_menu=False)
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76a5bac>}
nname: 310
n 310(None)[self.scan(_(tpset[1]), antenna, [-1], 0, user_config['tv']['scan_with_scrambled'])
]:
	i: 285(), 298()
	o: 

nname: 298
n 298(None)[]:
	i: 235(f)
	o: 310()

nname: 285
n 285(None)[]:
	i: 235(t)
	o: 310()

nname: 235
n 235(self.parent)[]:
	i: 213(), 234()
	o: 285(t), 298(f)

nname: 234
n 234(None)[]:
	i: 189(f)
	o: 235()

nname: 213
n 213(None)[log.warning('No antenna for this country seem to be listed in wyscan database')
]:
	i: 189(t)
	o: 235()

nname: 189
n 189(len(antenna_list) == 0)[del _[2]
for antenna_list in wyscanserver().GetAntenna(-1):
]:
	i: 115(AF), 185()
	o: 213(t), 234(f)

nname: 185
n 185(None)[]:
	i: 151(f), 174()
	o: 189()

nname: 174
n 174(None)[continue
]:
	i: 151(t)
	o: 185()

nname: 151
n 151(antenna[6] == tpset[0])[for antenna in wyscanserver().GetAntenna(-1):
]:
	i: 115(for)
	o: 174(t), 185(f)

nname: 115
n 115(None)[]:
	i: 93(), 114()
	o: 151(for), 189(AF)

nname: 114
n 114(None)[]:
	i: 69(f)
	o: 115()

nname: 93
n 93(None)[log.warning('Your country does not seem to be listed in wyscan database')
]:
	i: 69(t)
	o: 115()

nname: 69
n 69(len(tpset_list) == 0)[del _[1]
for tpset_list in wyscanserver().GetTransponderSets(-1, 1):
]:
	i: 0(AF), 65()
	o: 93(t), 114(f)

nname: 65
n 65(None)[]:
	i: 35(f), 54()
	o: 69()

nname: 54
n 54(None)[continue
]:
	i: 35(t)
	o: 65()

nname: 35
n 35(tp[1] == country)[for tp in wyscanserver().GetTransponderSets(-1, 1):
]:
	i: 0(for)
	o: 54(t), 65(f)

nname: 0
n 0(None)[country = 'none'
]:
	i: 
	o: 35(for), 69(AF)

nname: 310
n 310(None)[self.scan(_(tpset[1]), antenna, [-1], 0, user_config['tv']['scan_with_scrambled'])
]:
	i: 189()
	o: 

nname: 189
n 189(None)[del _[2]
for antenna_list in wyscanserver().GetAntenna(-1):
if len(antenna_list) == 0:
	log.warning('No antenna for this country seem to be listed in wyscan database')
if self.parent:
	pass
]:
	i: 69(AF), 151()
	o: 310()

nname: 151
n 151(None)[for antenna in wyscanserver().GetAntenna(-1):
if antenna[6] == tpset[0]:
	continue
]:
	i: 69(for)
	o: 189()

nname: 69
n 69(None)[del _[1]
for tpset_list in wyscanserver().GetTransponderSets(-1, 1):
if len(tpset_list) == 0:
	log.warning('Your country does not seem to be listed in wyscan database')
]:
	i: 0(AF), 35()
	o: 151(for), 189(AF)

nname: 35
n 35(None)[for tp in wyscanserver().GetTransponderSets(-1, 1):
if tp[1] == country:
	continue
]:
	i: 0(for)
	o: 69()

nname: 0
n 0(None)[country = 'none'
]:
	i: 
	o: 35(for), 69(AF)

nname: 189
n 189(None)[del _[2]
for antenna_list in wyscanserver().GetAntenna(-1):
if len(antenna_list) == 0:
	log.warning('No antenna for this country seem to be listed in wyscan database')
if self.parent:
	pass
self.scan(_(tpset[1]), antenna, [-1], 0, user_config['tv']['scan_with_scrambled'])
]:
	i: 69(AF), 151()
	o: 

nname: 151
n 151(None)[for antenna in wyscanserver().GetAntenna(-1):
if antenna[6] == tpset[0]:
	continue
]:
	i: 69(for)
	o: 189()

nname: 69
n 69(None)[del _[1]
for tpset_list in wyscanserver().GetTransponderSets(-1, 1):
if len(tpset_list) == 0:
	log.warning('Your country does not seem to be listed in wyscan database')
]:
	i: 0(AF), 35()
	o: 151(for), 189(AF)

nname: 35
n 35(None)[for tp in wyscanserver().GetTransponderSets(-1, 1):
if tp[1] == country:
	continue
]:
	i: 0(for)
	o: 69()

nname: 0
n 0(None)[country = 'none'
]:
	i: 
	o: 35(for), 69(AF)

self.nodes: {0: <unpyclib.structure.node instance at 0xb76aba8c>, 35: <unpyclib.structure.node instance at 0xb76abc4c>, 69: <unpyclib.structure.node instance at 0xb76ab12c>, 189: <unpyclib.structure.node instance at 0xb76ab62c>, 151: <unpyclib.structure.node instance at 0xb76ab5ac>}
nname: 6
n 6(None)[preview_list = None
def __init__(self, parent, *args, **args):
	ParametersSetupItem.__init__(self, *args, **kw)
	self.parent = parent

def scan(self, name, antenna, transponder, scan_network, include_scrambled):
	scan_item_list = [DVBSScanItem(wyscanserver(), name, antenna, transponder, scan_network, include_scrambled, menu=self.menu)]
	user_config['tv']['scan_with_scrambled'] = include_scrambled
	user_config.save()
	scan_item_list[0].player.play(scan_item_list[0], playlist=scan_item_list, hide_previous_menu=False)

def execute(self):
	country = 'none'

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb76a4a2c>}
nname: 120
n 120(None)[self.antenna = antenna
self.wyscanserver = server
self.transponder = transponder
self.scan_network = scan_network
self.include_scrambled = include_scrambled
self.high_lnb_power = high_lnb_power
return None
]:
	i: 47(JA), 89(JA), 116(), 119()
	o: 

nname: 119
n 119(None)[]:
	i: 0(f)
	o: 120()

nname: 116
n 116(None)[]:
	i: 114(AE)
	o: 120()

nname: 114
n 114(None)[]:
	i: 79(f)
	o: 116(AE)

nname: 89
n 89(None)[#, e
log.error('Unable to spawn ChannelScanner (%s)', e)
]:
	i: 79(t)
	o: 120(JA)

nname: 79
n 79(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 43(except)
	o: 89(t), 114(f)

nname: 47
n 47(None)[from pygui.menu.players import ChannelScanner
self.player = ChannelScanner()
]:
	i: 43(try)
	o: 120(JA)

nname: 43
n 43(None)[]:
	i: 0(t)
	o: 47(try), 79(except)

nname: 0
n 0(self.player is None)[Item.__init__(self, name, type_=type_, menu=menu)
]:
	i: 
	o: 43(t), 119(f)

nname: 120
n 120(None)[self.antenna = antenna
self.wyscanserver = server
self.transponder = transponder
self.scan_network = scan_network
self.include_scrambled = include_scrambled
self.high_lnb_power = high_lnb_power
return None
]:
	i: 47(JA), 89(JA), 79(f), 114(AE), 0(f)
	o: 

nname: 89
n 89(None)[#, e
log.error('Unable to spawn ChannelScanner (%s)', e)
]:
	i: 79(t)
	o: 120(JA)

nname: 79
n 79(<dummy_ex3> EXC_MATCH Exception)[]:
	i: 43(except)
	o: 89(t), 120(f)

nname: 47
n 47(None)[from pygui.menu.players import ChannelScanner
self.player = ChannelScanner()
]:
	i: 43(try)
	o: 120(JA)

nname: 43
n 43(None)[]:
	i: 0(t)
	o: 47(try), 79(except)

nname: 0
n 0(self.player is None)[Item.__init__(self, name, type_=type_, menu=menu)
]:
	i: 
	o: 43(t), 120(f)

nname: 120
n 120(None)[self.antenna = antenna
self.wyscanserver = server
self.transponder = transponder
self.scan_network = scan_network
self.include_scrambled = include_scrambled
self.high_lnb_power = high_lnb_power
return None
]:
	i: 79(f), 0(f)
	o: 

nname: 79
n 79(None)[except Exception, e:
	log.error('Unable to spawn ChannelScanner (%s)', e)
]:
	i: 43()
	o: 120(JA)

nname: 43
n 43(None)[try:
	from pygui.menu.players import ChannelScanner
	self.player = ChannelScanner()
]:
	i: 0(t)
	o: 79()

nname: 0
n 0(self.player is None)[Item.__init__(self, name, type_=type_, menu=menu)
]:
	i: 
	o: 43(t), 120(f)

nname: 120
n 120(None)[self.antenna = antenna
self.wyscanserver = server
self.transponder = transponder
self.scan_network = scan_network
self.include_scrambled = include_scrambled
self.high_lnb_power = high_lnb_power
return None
]:
	i: 43(f), 0(f)
	o: 

nname: 43
n 43(None)[try:
	from pygui.menu.players import ChannelScanner
	self.player = ChannelScanner()
except Exception, e:
	log.error('Unable to spawn ChannelScanner (%s)', e)
]:
	i: 0(t)
	o: 120(JA)

nname: 0
n 0(self.player is None)[Item.__init__(self, name, type_=type_, menu=menu)
]:
	i: 
	o: 43(t), 120(f)

nname: 0
n 0(None)[Item.__init__(self, name, type_=type_, menu=menu)
if self.player is None:
	try:
		from pygui.menu.players import ChannelScanner
		self.player = ChannelScanner()
	except Exception, e:
		log.error('Unable to spawn ChannelScanner (%s)', e)
self.antenna = antenna
self.wyscanserver = server
self.transponder = transponder
self.scan_network = scan_network
self.include_scrambled = include_scrambled
self.high_lnb_power = high_lnb_power
return None
]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb76a566c>}
nname: 6
n 6(None)[player = None
wyscanserver = None
def __init__(self, server, name, antenna, transponder, scan_network, include_scrambled=True, high_lnb_power=False, type_='dvbsscan', menu=None):
	Item.__init__(self, name, type_=type_, menu=menu)
	if self.player is None:
		try:
			from pygui.menu.players import ChannelScanner
			self.player = ChannelScanner()
		except Exception, e:
			log.error('Unable to spawn ChannelScanner (%s)', e)
	self.antenna = antenna
	self.wyscanserver = server
	self.transponder = transponder
	self.scan_network = scan_network
	self.include_scrambled = include_scrambled
	self.high_lnb_power = high_lnb_power
	return None

]:
	i: 
	o: 

self.nodes: {6: <unpyclib.structure.node instance at 0xb76a496c>}
nname: 0
n 0(None)[from __future__ import absolute_import
from time import gmtime, strftime
from . import ParametersSetupItem
from pygui.item.core import Item, ActionItem
import pygui.config as config
from pygui.config import user_config
from wyrecord import WyRecord
from . import wyscanserver
from peewee.debug import GET_LOGGER
log = GET_LOGGER(__name__)
from .. import UserConfigSetupItem, BooleanUserConfigSetupItem
class FirstbootTNTScanSetupItem(ParametersSetupItem):
	def browse(self):
		return [ActionItem(name=_('Yes'), type_='setupitem', action=(lambda : TNTAutomaticScanItem(parent=None, name=_('Yes'), menu=self.menu, type_='setupitem').execute())), ActionItem(name=_('No'), type_='setupitem', action=(lambda : self.menu._set_options_list(None)))]



class EPGMarginItem(UserConfigSetupItem):
	depth = 2
	translation_dict = {}
	def __init__(self, *args, **args):
		if not EPGMarginItem.translation_dict:
			for d in config.HMI_TV['epg_margins']:
				_d = d * 60
				EPGMarginItem.translation_dict[d] = strftime(_('%M min'), gmtime(_d))
		UserConfigSetupItem.__init__(self, *args, **kw)

	def _select_option(self, val):
		UserConfigSetupItem._select_option(self, val)
		WyRecord().setRecordPadding(val * 60)



class TNTScanMenuSetupItem(ParametersSetupItem):
	depth = 2
	def __init__(self, *args, **args):
		ParametersSetupItem.__init__(self, *args, **kw)
		self.include_scrambled = user_config['tv']['scan_with_scrambled']
		if self.include_scrambled:
			pass
		self.all_channels_item = ActionItem(_('Free and pay channels'), type_='setupitem', display_type='not_checked', action=self.set_include_scrambled, args=(True,))
		if self.include_scrambled:
			pass
		self.free_channels_only_item = ActionItem(_('Free channels only'), type_='setupitem', display_type='checked', action=self.set_include_scrambled, args=(False,))
		self.preview_list = [self.all_channels_item, self.free_channels_only_item, TNTAutomaticScanItem(parent=self, name='Start scan', type_='setupitem')]

	def set_include_scrambled(self, value):
		self.include_scrambled = value
		if value:
			pass
		self.all_channels_item.display_type = 'not_checked'
		if value:
			pass
		self.free_channels_only_item.display_type = 'checked'
		self.all_channels_item.reset_view()
		self.free_channels_only_item.reset_view()



class ExternalAntenna(BooleanUserConfigSetupItem):
	depth = 2
	def execute_action(self, value):
		wyscanserver().EnableHighLnbVoltage(1, value)



class TNTAutomaticScanItem(ParametersSetupItem):
	preview_list = None
	def __init__(self, parent, *args, **args):
		ParametersSetupItem.__init__(self, *args, **kw)
		self.parent = parent

	def scan(self, name, antenna, transponder, scan_network, include_scrambled):
		scan_item_list = [DVBSScanItem(wyscanserver(), name, antenna, transponder, scan_network, include_scrambled, menu=self.menu)]
		user_config['tv']['scan_with_scrambled'] = include_scrambled
		user_config.save()
		scan_item_list[0].player.play(scan_item_list[0], playlist=scan_item_list, hide_previous_menu=False)

	def execute(self):
		country = 'none'



class DVBSScanItem(Item):
	player = None
	wyscanserver = None
	def __init__(self, server, name, antenna, transponder, scan_network, include_scrambled=True, high_lnb_power=False, type_='dvbsscan', menu=None):
		Item.__init__(self, name, type_=type_, menu=menu)
		if self.player is None:
			try:
				from pygui.menu.players import ChannelScanner
				self.player = ChannelScanner()
			except Exception, e:
				log.error('Unable to spawn ChannelScanner (%s)', e)
		self.antenna = antenna
		self.wyscanserver = server
		self.transponder = transponder
		self.scan_network = scan_network
		self.include_scrambled = include_scrambled
		self.high_lnb_power = high_lnb_power
		return None



]:
	i: 
	o: 

self.nodes: {0: <unpyclib.structure.node instance at 0xb769858c>}
from __future__ import absolute_import
from time import gmtime, strftime
from . import ParametersSetupItem
from pygui.item.core import Item, ActionItem
import pygui.config as config
from pygui.config import user_config
from wyrecord import WyRecord
from . import wyscanserver
from peewee.debug import GET_LOGGER
log = GET_LOGGER(__name__)
from .. import UserConfigSetupItem, BooleanUserConfigSetupItem
class FirstbootTNTScanSetupItem(ParametersSetupItem):
	def browse(self):
		return [ActionItem(name=_('Yes'), type_='setupitem', action=(lambda : TNTAutomaticScanItem(parent=None, name=_('Yes'), menu=self.menu, type_='setupitem').execute())), ActionItem(name=_('No'), type_='setupitem', action=(lambda : self.menu._set_options_list(None)))]



class EPGMarginItem(UserConfigSetupItem):
	depth = 2
	translation_dict = {}
	def __init__(self, *args, **args):
		if not EPGMarginItem.translation_dict:
			for d in config.HMI_TV['epg_margins']:
				_d = d * 60
				EPGMarginItem.translation_dict[d] = strftime(_('%M min'), gmtime(_d))
		UserConfigSetupItem.__init__(self, *args, **kw)

	def _select_option(self, val):
		UserConfigSetupItem._select_option(self, val)
		WyRecord().setRecordPadding(val * 60)



class TNTScanMenuSetupItem(ParametersSetupItem):
	depth = 2
	def __init__(self, *args, **args):
		ParametersSetupItem.__init__(self, *args, **kw)
		self.include_scrambled = user_config['tv']['scan_with_scrambled']
		if self.include_scrambled:
			pass
		self.all_channels_item = ActionItem(_('Free and pay channels'), type_='setupitem', display_type='not_checked', action=self.set_include_scrambled, args=(True,))
		if self.include_scrambled:
			pass
		self.free_channels_only_item = ActionItem(_('Free channels only'), type_='setupitem', display_type='checked', action=self.set_include_scrambled, args=(False,))
		self.preview_list = [self.all_channels_item, self.free_channels_only_item, TNTAutomaticScanItem(parent=self, name='Start scan', type_='setupitem')]

	def set_include_scrambled(self, value):
		self.include_scrambled = value
		if value:
			pass
		self.all_channels_item.display_type = 'not_checked'
		if value:
			pass
		self.free_channels_only_item.display_type = 'checked'
		self.all_channels_item.reset_view()
		self.free_channels_only_item.reset_view()



class ExternalAntenna(BooleanUserConfigSetupItem):
	depth = 2
	def execute_action(self, value):
		wyscanserver().EnableHighLnbVoltage(1, value)



class TNTAutomaticScanItem(ParametersSetupItem):
	preview_list = None
	def __init__(self, parent, *args, **args):
		ParametersSetupItem.__init__(self, *args, **kw)
		self.parent = parent

	def scan(self, name, antenna, transponder, scan_network, include_scrambled):
		scan_item_list = [DVBSScanItem(wyscanserver(), name, antenna, transponder, scan_network, include_scrambled, menu=self.menu)]
		user_config['tv']['scan_with_scrambled'] = include_scrambled
		user_config.save()
		scan_item_list[0].player.play(scan_item_list[0], playlist=scan_item_list, hide_previous_menu=False)

	def execute(self):
		country = 'none'



class DVBSScanItem(Item):
	player = None
	wyscanserver = None
	def __init__(self, server, name, antenna, transponder, scan_network, include_scrambled=True, high_lnb_power=False, type_='dvbsscan', menu=None):
		Item.__init__(self, name, type_=type_, menu=menu)
		if self.player is None:
			try:
				from pygui.menu.players import ChannelScanner
				self.player = ChannelScanner()
			except Exception, e:
				log.error('Unable to spawn ChannelScanner (%s)', e)
		self.antenna = antenna
		self.wyscanserver = server
		self.transponder = transponder
		self.scan_network = scan_network
		self.include_scrambled = include_scrambled
		self.high_lnb_power = high_lnb_power
		return None



